using Microsoft.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Modeling;
using Volo.Abp.EntityFrameworkCore.DependencyInjection;
using Joy.Erp.BasicArchives.EntityFrameworkCore;

namespace Joy.Erp.BasicArchives.Sales
{
    public class SaleOrderTypeModelConfiguration : IModelConfiguration
    {
        public void Build(ModelBuilder builder)
        {
            builder.Entity<SaleOrderType>(b =>
            {
                b.ToTable(BasicArchivesDbProperties.DbTablePrefix + nameof(SaleOrderType), BasicArchivesDbProperties.DbSchema);
                b.ConfigureByConvention();
                b.ConfigureArchiveAggregateRoot();

                b.Property(x => x.DisplayName).HasMaxLength(SaleOrderTypeConsts.DisplayNameMaxLength);
                b.Property(x => x.DisplayName).IsRequired(SaleOrderTypeConsts.DisplayNameRequired);
            });
        }

        public void Entity(IAbpDbContextRegistrationOptionsBuilder options)
        {
            options.Entity<SaleOrderType>(opt =>
            {
                opt.DefaultWithDetailsFunc = query =>
                {
                    return query
                        ;
                };
            });
        }
    }
} 